<?php

/*
 *
 */

class Model_Mediate_CallRecord extends Model_BaseModel
{
    use Lib_BaseTraits;
    /**
     * 缓存前缀
     *
     * @var unknown
     */
    private static $tag = 'Model_Mediate_CallRecord';
    /**
     * Undocumented variable.
     *
     * @var string
     */
    private $table = 'call_record';

    public function __construct()
    {
        // 选择连接的数据库
        parent::_init('mediation');
    }
    //获取通话记录
    public function getRecordByCaseIds($caseIds,$where)
    {
        $sql = "SELECT
                    call_record.*,
                    cases.litigantName,
                    cases.batshId,
                    cases.contractNo,
                    cases.mediationNum,
                    cases.assetsName
                FROM call_record
                LEFT JOIN cases
                ON  call_record.caseId = cases.id
                WHERE
                    call_record.caseId in ({$caseIds})
                ";
        if($where){
            if(isset($where) && !empty($where)){
                $sql .= ' AND '.implode(' AND ',$where);
            }
        }
        return $this->dao->conn()->setTag(self::$tag)->preparedSql($sql, [])->fetchAll();

    }
}
